package com.daxt.webservice;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.daxt.base.common.util.RedisUtil;
import com.daxt.common.result.Result;
import com.daxt.common.util.DateUtil;
import com.daxt.mapper.accept.ArchivesAcceptTokenMapper;
import com.daxt.mapper.accept.WorkOrderMapper;
import com.daxt.mapper.archives.ArchivesDocMapper;
import com.daxt.mapper.archives.ArchivesTestingFourRecordMapper;
import com.daxt.mapper.sys.ArchivesClassMapper;
import com.daxt.mapper.sys.ArchivesFondsMapper;
import com.daxt.mapper.sys.ArchivesTypeMapper;
import com.daxt.mapper.sys.DicMapper;
import com.daxt.model.dic.SystemConfigType;
import com.daxt.model.ftp.Ftp;
import com.daxt.model.service.accept.vo.ArchivesAcceptToken;
import com.daxt.model.service.accept.vo.WorkOrder;
import com.daxt.model.service.archives.vo.*;
import com.daxt.model.service.base.vo.Dic;
import com.daxt.service.ArchivesTestingFourService;
import com.daxt.service.MountService;
import com.daxt.service.UploadService;
import com.daxt.utils.FtpUtil;
import com.daxt.utils.XmlDomUtil;
import com.daxt.utils.ZipUtil;
import com.daxt.utils.file.FileBaseUtil;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import java.io.*;
import java.time.LocalDateTime;
import java.util.*;


/**
 *  通过webService的方式对外提供接口
 *  oa校验码：30159a773aa9de9243541c36871ccaca  OA123@#￥%
 *  集团oa校验码：99a45eec1d3b1018c950e4490a822cca  JTOA123@#￥%
 *  zb校验码：B0BA3E425F38B8021F6622CE8401D981  ZB123@#￥%
 *  档案系统单位编码：a473bb66497b71c5b31345da921673db   dangandanwei!!@@123
 */
@WebService
@Service
public class AcceptWebServiceImpl implements  AcceptWebService {
    @Autowired
    private ArchivesDocMapper archivesDocMapper;
    @Autowired
    private MountService mountService;
    @Autowired
    private UploadService uploadService;
    @Autowired
    private ArchivesTestingFourService archivesTestingFourService;
    @Autowired
    private ArchivesTestingFourRecordMapper archivesTestingFourRecordMapper;
    @Autowired
    private WorkOrderMapper workOrderMapper;
    @Autowired
    private DicMapper dicMapper;
    @Autowired
    private ArchivesClassMapper archivesClassMapper;
    @Autowired
    private ArchivesTypeMapper archivesTypeMapper;
    @Autowired
    private ArchivesFondsMapper archivesFondsMapper;
    @Autowired
    private ArchivesAcceptTokenMapper acceptTokenMapper;

    @Value("${ftp.downPath}")
    private String ftpDownPath;
    @Value("${ftp.ip}")
    private String ftpIp;
    @Value("${ftp.userName}")
    private String ftpUserName;
    @Value("${ftp.pwd}")
    private String ftpPwd;

    /**
     * 用于路桥集团中的其它系统预归档到电子文件归档处理系统，在线接收归档格式包
     */
    @WebMethod(operationName = "receiveArchiveRequest")
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String receiveArchiveRequest(@WebParam(name = "jsonData") String jsonData) {
        Map<String,String> result=new HashMap<String,String>();

        System.out.println("开始调用接口:"+jsonData);
        //判断是否是json格式
        if(!isJson(jsonData)){
            result.put("code","501");
            result.put("msg","参数有误，不是json格式");
            //return "上传失败，参数不是json格式";
            return JSON.toJSONString(result);
        }

        //判断参数是否是空参数
        WorkOrder workOrder= JSON.parseObject(jsonData,WorkOrder.class);
        workOrder.setCreateData(LocalDateTime.now());
        if (isWorkOrder(workOrder)){
            result.put("code","501");
            result.put("msg","参数有误，参数存在空数据！");

            workOrder.setState("0");
            workOrder.setReason(result.get("msg"));
            workOrderMapper.insert(workOrder);
            return JSON.toJSONString(result);
        }

        String appId=workOrder.getAppId();

        QueryWrapper<ArchivesAcceptToken> acceptTokenQueryWrapper=new QueryWrapper<>();
        acceptTokenQueryWrapper.eq("systemName",appId);
        ArchivesAcceptToken acceptToken=acceptTokenMapper.selectOne(acceptTokenQueryWrapper);

        //校验接口名称与接口校验码
        if(acceptToken==null){
            result.put("code","504");
            result.put("msg","接口名称"+appId+"不存在！");

            workOrder.setState("0");
            workOrder.setReason(result.get("msg"));
            //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
            workOrder.setFailCount(1);
            workOrderMapper.insert(workOrder);
            return JSON.toJSONString(result);
        }else{
            String md5Str = DigestUtils.md5DigestAsHex(workOrder.getAppToken().getBytes());
            if("ZB".equals(appId)){
                //接口名称+接口调用方的单位名称+归档日期
                String str=appId+workOrder.getCompanyCode()+workOrder.getGdsj();
                md5Str = DigestUtils.md5DigestAsHex(str.getBytes());
                //System.out.println("md5Str:"+md5Str);
            }

            //离隰公司OA
            if("OA".equals(appId) && !acceptToken.getToken().equals(md5Str)){
                result.put("code","505");
                result.put("msg","接口校验码错误!");

                workOrder.setState("0");
                workOrder.setReason(result.get("msg"));
                //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
                workOrder.setFailCount(1);
                workOrderMapper.insert(workOrder);
                return JSON.toJSONString(result);
            }
            //集团总部OA
            if("JTOA".equals(appId) && !acceptToken.getToken().equals(md5Str)){
                result.put("code","505");
                result.put("msg","接口校验码错误!");

                workOrder.setState("0");
                workOrder.setReason(result.get("msg"));
                //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
                workOrder.setFailCount(1);
                workOrderMapper.insert(workOrder);
                return JSON.toJSONString(result);
            }

            //质保资料系统
            if("ZB".equals(appId) && !workOrder.getAppToken().equals(md5Str)){
                result.put("code","505");
                result.put("msg","接口校验码错误!");

                workOrder.setState("0");
                workOrder.setReason(result.get("msg"));
                //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
                workOrder.setFailCount(1);
                workOrderMapper.insert(workOrder);
                return JSON.toJSONString(result);
            }
        }

        //校验单位名称
        if("OA".equals(appId) || "ZB".equals(appId)){
            if(!"离隰公司".equals(workOrder.getCompanyCode())){
                result.put("code","506");
                result.put("msg","单位名称校验错误!");

                workOrder.setState("0");
                workOrder.setReason(result.get("msg"));
                //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
                workOrder.setFailCount(1);
                workOrderMapper.insert(workOrder);
                return JSON.toJSONString(result);
            }
        }else if ("JTOA".equals(appId)){
            if(!"集团总部".equals(workOrder.getCompanyCode())){
                result.put("code","506");
                result.put("msg","单位名称校验错误!");

                workOrder.setState("0");
                workOrder.setReason(result.get("msg"));
                //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
                workOrder.setFailCount(1);
                workOrderMapper.insert(workOrder);
                return JSON.toJSONString(result);
            }
        }else{
            result.put("code","506");
            result.put("msg","单位名称校验错误!");

            workOrder.setState("0");
            workOrder.setReason(result.get("msg"));
            //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
            workOrder.setFailCount(1);
            workOrderMapper.insert(workOrder);
            return JSON.toJSONString(result);
        }


        //String savePath="F:/zjq/档案系统路桥文档/案件归档任务包-模拟/";
        //下载zip包
        String ossDir = RedisUtil.getSysConfig(SystemConfigType.OSS_DIR);
        String savePath=ossDir+"/receive/";
        if(!workOrder.getSclj().endsWith("/")){
            workOrder.setSclj(workOrder.getSclj()+"/");
        }
        //if("OA".equals(appId)){  //oa的时候是放开的，现在注释了！
        savePath=savePath+workOrder.getSclj();;
        savePath=savePath.replace("//","/");
        //}

        String downPath = ftpDownPath + workOrder.getSclj();
        //String downPath="/home/ftptest/"+workOrder.getSclj();
        //String downPath="/home/ftps/"+workOrder.getSclj();
        String fileName=workOrder.getScmc();

        //判断系统中是否存在此zip文件，若存在则删除此文件，再进行下载
        File zipScmc=new File(savePath+fileName);
        //System.out.println("下载前的zip文件:"+savePath+fileName);
        if (zipScmc.exists()){
            zipScmc.delete();
        }

        if(!downZip(downPath,savePath,fileName)){
            result.put("code","502");
            result.put("msg",fileName+"文件下载失败");

            workOrder.setState("0");
            workOrder.setReason(result.get("msg"));
            //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
            workOrder.setFailCount(1);
            workOrderMapper.insert(workOrder);
            return JSON.toJSONString(result);
        }
        String zipFilePath=savePath+fileName;

        workOrder.setSavePath(zipFilePath);

        File zipfile=new File(zipFilePath);


        //判断是否是zip文件
        if(zipfile.exists()) {
            //获取zip文件后缀
            String ext = FileBaseUtil.getFileExtName(zipfile);
            //System.out.println("ext:" + ext);
            if (!"zip".equals(ext)) {
                result.put("code","503");
                result.put("msg",fileName+"解析失败，压缩文件不合法！");

                workOrder.setState("0");
                workOrder.setReason(result.get("msg"));
                //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
                workOrder.setFailCount(1);
                workOrderMapper.insert(workOrder);
                return JSON.toJSONString(result);
            }
        }
        //判断zip解压后的目录是否存在，若存在则删除，再进行解压操作
        String zipScmcMuLu=savePath+fileName.replace(".zip","");
        File zipMuLu=new File(zipScmcMuLu);
        if (zipMuLu.exists()){
            try {
                FileUtils.deleteDirectory(zipMuLu);
            }catch (IOException io){
                io.printStackTrace();
            }
        }


        //获取文件解压路径
        //String zipFileName="oa-bgs-123456.zip";
        //String zipPath= FileBaseUtil.getFileNameFront(path);
        String zipPath=savePath;
        //System.out.println("解压路径："+zipPath);

        //解压zip文件包
        try {
            File[] files= ZipUtil.unzip(zipfile,zipPath,"");
        }catch (ZipException e){
            e.printStackTrace();
            result.put("code","503");
            result.put("msg",fileName+"解析失败，压缩文件不合法！");

            workOrder.setState("0");
            workOrder.setReason(result.get("msg"));
            //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
            workOrder.setFailCount(1);
            workOrderMapper.insert(workOrder);
            return JSON.toJSONString(result);
        }


        //获取解压后的路径
        zipPath= FileBaseUtil.getFileNameFront(zipFilePath);
        System.out.println("zip文件夹解压后的路径是："+zipPath);

        //判断是案卷还是案件
        if(workOrder.getRwblx().equals("文件")){
            //解析案件
            String anJianResult= getAnJian(zipPath,appId,workOrder);
            if(anJianResult!=null){
                return anJianResult;
            }
        }else if(workOrder.getRwblx().equals("案卷")){
            //解析案卷
            String anJuanResult=getAnJuan(zipPath,appId,workOrder);
            if(anJuanResult!=null){
                return anJuanResult;
            }
        }

        result.put("code","200");
        result.put("msg","成功受理归档任务包。");
        //workOrder.setSuccessCount(Integer.parseInt(workOrder.getSl()));
        workOrder.setSuccessCount(1);
        workOrder.setState("1");
        workOrderMapper.insert(workOrder);
        return JSON.toJSONString(result);
    }



    /*@WebMethod
    public String datafeedback(@WebParam(name="dataName") String dataName,@WebParam(name="detectionCode") String detectionCode,
        @WebParam(name="detectionMsg") String detectionMsg) {

        return null;
    }*/

    /**
     * @description: 解析案件
     *
     * @param zipPath 数据包解压后的路径
     * @param appId  接口类型
     * @date: 2022/10/26
     */
    private String getAnJian(String zipPath,String appId,WorkOrder workOrder){
        Map<String,String> result=new HashMap<String,String>();
        //解析list.xml文件
        File file=new File(zipPath+"/list.xml");
        if (!file.exists()){
            result.put("code","508");
            result.put("msg","四性检测失败，"+zipPath+"/list.xml文件不存在!");

            workOrder.setState("0");
            workOrder.setReason(result.get("msg"));
            //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
            workOrder.setFailCount(1);
            workOrderMapper.insert(workOrder);

            return JSON.toJSONString(result);
        }
        Map<String,List> mapList = XmlDomUtil.domXml(zipPath+"/list.xml");
        //获取案件目录判断是否存在
        List<String> listDocPath=getDocPath(mapList);
        String isExists= isExists(zipPath,listDocPath);
        if(!"true".equals(isExists)){
            result.put("code","507");
            result.put("msg","案件中"+isExists+"目录不存在!");

            workOrder.setState("0");
            workOrder.setReason(result.get("msg"));
            //workOrder.setFailCount(Integer.parseInt(workOrder.getSl()));
            workOrder.setFailCount(1);
            workOrderMapper.insert(workOrder);
            return JSON.toJSONString(result);
        }


        //解析案件的doc.xml
        for(int i=0;i<listDocPath.size();i++){
            String docPath=listDocPath.get(i);
            File file2=new File(zipPath+docPath+"/doc.xml");
            if (!file2.exists()){
                result.put("code","508");
                result.put("msg","四性检测失败，"+zipPath+docPath+"doc.xml文件不存在!");


                workOrder.setState("0");
                workOrder.setReason(result.get("msg"));
                //workOrder.setFailCount(Integer.parseInt(workOrder.getSl())-i);
                //workOrder.setSuccessCount(Integer.parseInt(workOrder.getSl())-(Integer.parseInt(workOrder.getSl())-i));
                workOrder.setFailCount(1);
                workOrder.setSuccessCount(0);
                workOrderMapper.insert(workOrder);

                return JSON.toJSONString(result);
            }
            Map<String,List> mapDoc = XmlDomUtil.domXml(zipPath+docPath+"/doc.xml");
            ArchivesDoc doc=new ArchivesDoc();
            doc.setTypeId(0L);
            doc.setDossierId(0L);
            doc.setState("6");
            doc.setFileType("doc");
            doc.setIsDelete("0");
            doc.setCreateTime(LocalDateTime.now());
            doc.setDutyCompany(workOrder.getCompanyCode());
            List<List<String>> listOne=mapDoc.get("1");
            for (int j=0;j<listOne.size();j++){
                List<String> list=listOne.get(j);
                //if(j==0) list.get(1);  聚合层次
                if(j==1) doc.setItemCode(list.get(1)); // 任务单编号
                //if(j==2) doc.setItemCode(list.get(1));   //源系统id
            }
            List<List<String>> listTwo=mapDoc.get("1_3->2");
            String flowName="";
            for (int j=0;j<listTwo.size();j++){
                List<String> list=listTwo.get(j);
                //给案件字段赋值
                if("OA".equals(appId)){
                    doc.setDocFrom("2");
                    doc.setSource("OA");
                    if(j==0)  {
                        flowName=list.get(1); //审批流程名称
                        doc.setExt14(flowName);
                    }
                    getOaDoc(j,doc,list,flowName);
                }
                if("JTOA".equals(appId)){
                    doc.setDocFrom("5");
                    doc.setSource("JTOA");
                    getJtOaDoc(j,doc,list);
                }
            }

            List<String> listFilePath= new ArrayList<>();
            List<String> listFileName= new ArrayList<>();
            List<String> keys=new ArrayList<>();
            for(String key:mapDoc.keySet()){
                if(!key.contains("1_4->2_")){
                    continue;
                }
                keys.add(key);
            }

            List<String> fileNames=new ArrayList<>();
            for(int j=0;j<keys.size();j++){
                String key="1_4->2_"+j+"->3";
                List<List<String>> listThree=mapDoc.get(key);
                for (int k=0;k<listThree.size();k++){
                    List<String> list=listThree.get(k);
                    if(k==0){
                        String fileNameFront=FileBaseUtil.getFileNameFront(list.get(1));

                        if(fileNames.contains(fileNameFront)){
                            listFileName.add(list.get(1).replace(fileNameFront,fileNameFront+"2")); //文件名
                        }else{
                            listFileName.add(list.get(1)); //文件名
                        }
                        fileNames.add(fileNameFront);

                    }
                    if(k==1) listFilePath.add(list.get(1)); //存储路径
                }
            }

            //四性检测
            if("OA".equals(appId) || "JTOA".equals(appId)){
                //进行四性检测
                doc.setDocTotalSize(workOrder.getScdx());
                Result r = archivesTestingFourService.fourDetection(doc,workOrder,listFilePath,zipPath);
                QueryWrapper<ArchivesTestingFourRecord> fourRecordQueryWrapper=new QueryWrapper<>();
                fourRecordQueryWrapper.eq("docId","-1");
                fourRecordQueryWrapper.eq("test","false");
                fourRecordQueryWrapper.eq("source",appId);
                List<ArchivesTestingFourRecord> ArchivesTestingFourRecords= archivesTestingFourRecordMapper.selectList(fourRecordQueryWrapper);

                if(ArchivesTestingFourRecords.size()<=0){
                    //四性检测通过
                    int count= archivesDocMapper.selectCount(new QueryWrapper<ArchivesDoc>().eq("itemCode",doc.getItemCode()));
                    //去重操作，去除重复性数据
                    if (count>=1){
                        continue;
                    }
                    archivesDocMapper.insert(doc);
                    UpdateWrapper<ArchivesTestingFourRecord> fourRecordUpdateWrapper=new UpdateWrapper<>();
                    fourRecordUpdateWrapper.set("docId",doc.getId());
                    fourRecordUpdateWrapper.eq("docId","-1");
                    archivesTestingFourRecordMapper.update(null,fourRecordUpdateWrapper);
                }else{
                    //四性检测未通过
                    String msg="";
                    for(int j=0;j<ArchivesTestingFourRecords.size();j++){
                        msg=msg+ArchivesTestingFourRecords.get(j).getDescribes()+";";
                    }
                    result.put("code","508");
                    result.put("msg","四性检测失败，"+msg.replace("true",""));

                    workOrder.setState("0");
                    workOrder.setReason(result.get("msg"));
                    //workOrder.setFailCount(Integer.parseInt(workOrder.getSl())-i);
                    //workOrder.setSuccessCount(Integer.parseInt(workOrder.getSl())-(Integer.parseInt(workOrder.getSl())-i));
                    workOrder.setFailCount(1);
                    workOrder.setSuccessCount(0);
                    workOrderMapper.insert(workOrder);

                    //删除四性检测记录
                    Map<String, Object> map = new HashMap<>();
                    map.put("docId","-1");
                    map.put("source","OA");
                    archivesTestingFourRecordMapper.deleteByMap(map);

                    return JSON.toJSONString(result);
                }

            }


            for (int j=0;j<listFilePath.size();j++){
                uploadFile(doc,zipPath+listFilePath.get(j),listFileName.get(j),appId);
            }
        }

        return null;
    }


    /**
     * @description: 解析案卷
     * 
     * @date: 2022/10/25
     */
    private String getAnJuan(String zipPath,String appId,WorkOrder workOrder){


        Map<String,String> result=new HashMap<String,String>();

        //判断list.xml文件是否存在
        String listFile=zipPath+"/list.xml";
        File file=new File(listFile);
        if(!file.exists()){
            result.put("code","507");
            result.put("msg","四性检测失败，list.xml 文件不存在！");
            return JSON.toJSONString(result);
        };

        //解析list.xml文件
        Map<String,List> mapList=null;
        try {
            mapList= XmlDomUtil.domXml(listFile);
        }catch (Exception e){
            result.put("code","507");
            result.put("msg","四性检测失败，list.xml解析异常");
            return JSON.toJSONString(result);
        }
        //获取案件与案卷目录判断是否存在
        List<String> listDossPath=getDossPath(mapList);
        String isExists= isExists(zipPath,listDossPath);
        if(!"true".equals(isExists)){
            result.put("code","507");
            result.put("msg","四性检测失败，案卷中"+isExists+"目录不存在！");
            return JSON.toJSONString(result);
        }
        List<String> listDocPath=getDossDocPath(mapList);
        isExists= isExists(zipPath,listDocPath);
        if(!"true".equals(isExists)){
            result.put("code","507");
            result.put("msg","四性检测失败，案卷中的案件"+isExists+"目录不存在！");
            return JSON.toJSONString(result);
        }

        //判断 vol.xml文件是否存在
        List<String> pdfList=new ArrayList();  //保存所有pdf文件的名字
        for (int i=0;i<listDossPath.size();i++){

            if(!new File(zipPath+listDossPath.get(i)+"/vol.xml").exists()){
                result.put("code","507");
                result.put("msg","四性检测失败，"+listDossPath.get(i)+"/vol.xml 文件不存在！");
                return JSON.toJSONString(result);
            };
            //判断 doc.xml文件是否存在
            for(int j=0;j<listDocPath.size();j++){
                if(!new File(zipPath+listDocPath.get(j)+"doc.xml").exists()){
                    result.put("code","507");
                    result.put("msg","四性检测失败，"+zipPath+listDocPath.get(j)+"doc.xml 文件不存在！");
                    return JSON.toJSONString(result);
                }
                File pdfMkdir=new File(zipPath+listDocPath.get(j));
                File[] files= pdfMkdir.listFiles();
                if(files!=null){
                    for (File file1 : files){
                        if(file1.getName().contains(".pdf")){
                            String fileAbsolutePath=file1.getAbsolutePath().replace("\\","/");
                            pdfList.add(fileAbsolutePath.replace(zipPath,""));
                        }
                    }
                }
            }
        }
        if(Integer.parseInt(workOrder.getSl())!= listDocPath.size()){
            result.put("code","508");
            result.put("msg","四性检测失败，电子档案数量与实际案件个数不一致，实际个数是："+listDocPath.size()+"填写个数是："+workOrder.getSl());
            return JSON.toJSONString(result);
        }


        //获取对应的typeId，fondsid
        Long fondsId=0L;
        Long typeId=0L;
        String genItemNum=null;
        String genDossierNum=null;
        //int sort=1;
        //Long shiGongClassId=0L;
        //String treeStr="";
        if("ZB".equals(appId) ){
            ArchivesFonds archivesFonds = archivesFondsMapper.selectOne(new QueryWrapper<ArchivesFonds>().like("fondsName","离隰"));
            QueryWrapper<ArchivesType> typeQueryWrapper= new QueryWrapper<>();
            fondsId=archivesFonds.getId();
            typeQueryWrapper.eq("typeName","项目建设类");
            typeQueryWrapper.eq("fondsId",fondsId);
            ArchivesType archivesType= archivesTypeMapper.selectOne(typeQueryWrapper);
            if(archivesType!=null){
                typeId=archivesType.getId();
                genItemNum=archivesType.getGenItemNum();
                genDossierNum=archivesType.getGenDossierNum();
            }else{
                result.put("code","508");
                result.put("msg","四性检测失败，请先联系档案管理员，建立对应门类（门类名称为:项目建设类）！");
                return JSON.toJSONString(result);
            }
        }


        for(int i=0;i<listDossPath.size();i++){

            int dossPages=0;

            String dossPath=listDossPath.get(i);
            //解析案卷中的vol.xml
            Map<String,List> mapVol=null;
            try {
                mapVol = XmlDomUtil.domXml(zipPath+dossPath+"/vol.xml");
            }catch (Exception e){
                result.put("code","508");
                result.put("msg","四性检测失败，vol.xml解析异常");
                return JSON.toJSONString(result);
            }


            //设置案卷信息
            ArchivesDoc archivesDoss=getArchivesDoss(mapVol,appId,fondsId,typeId);
            archivesDoss.setDutyCompany(workOrder.getCompanyCode());

            //此处需要进行四性检测，后续处理
            if("ZB".equals(appId)) {
                if(archivesDoss.getClassId()==null){
                    result.put("code","508");
                    result.put("msg","四性检测失败，请先联系档案管理员，建立对应分类(门类id不存在！)");
                    return JSON.toJSONString(result);
                }


                //进行四性检测
                archivesDoss.setDocTotalSize(workOrder.getScdx());


                /*Result r = archivesTestingFourService.fourDetection(archivesDoss, workOrder, pdfList, zipPath);

                QueryWrapper<ArchivesTestingFourRecord> fourRecordQueryWrapper=new QueryWrapper<>();
                fourRecordQueryWrapper.eq("docId","-1");
                fourRecordQueryWrapper.eq("test","false");
                fourRecordQueryWrapper.eq("source","ZB");
                List<ArchivesTestingFourRecord> ArchivesTestingFourRecords= archivesTestingFourRecordMapper.selectList(fourRecordQueryWrapper);

                if(ArchivesTestingFourRecords.size()>0){
                    //四性检测未通过
                    String msg="";
                    for(int j=0;j<ArchivesTestingFourRecords.size();j++){
                        msg=msg+ArchivesTestingFourRecords.get(j).getDescribes()+";";
                    }/workOrder
                    result.put("code","508");
                    result.put("msg","四性检测失败，"+msg.replace("true",""));

                    workOrder.setState("0");
                    workOrder.setReason(result.get("msg"));
                    //workOrder.setFailCount(Integer.parseInt(workOrder.getSl())-i);
                    //workOrder.setSuccessCount(Integer.parseInt(workOrder.getSl())-(Integer.parseInt(workOrder.getSl())-i));
                    workOrder.setSuccessCount(0);
                    workOrder.setFailCount(1);
                    workOrderMapper.insert(workOrder);

                    //删除四性检测记录
                    Map<String, Object> map = new HashMap<>();
                    map.put("docId","-1");
                    map.put("source","ZB");
                    archivesTestingFourRecordMapper.deleteByMap(map);

                    return JSON.toJSONString(result);
                }*/

            }

            //去重操作
            QueryWrapper<ArchivesDoc> dossQueryWrapper= new QueryWrapper<>();
            dossQueryWrapper.eq("itemCode",archivesDoss.getItemCode());
            if("ZB".equals(appId)) {
                dossQueryWrapper.eq("typeId",archivesDoss.getTypeId());
                dossQueryWrapper.eq("classId",archivesDoss.getClassId());
                dossQueryWrapper.eq("fondsId",fondsId);
            }
            ArchivesDoc archivesDoc1= archivesDocMapper.selectOne(dossQueryWrapper);
            if(archivesDoc1==null){
                //设置卷号
                if(StringUtils.isNotEmpty(genDossierNum)){
                    List<String> states=new ArrayList<>();
                    states.add("0");
                    states.add("1");
                    states.add("2");
                    states.add("6");

                    QueryWrapper<ArchivesDoc> queryWrapper=new QueryWrapper<>();
                    queryWrapper.eq("dossierId","0");
                    queryWrapper.eq("fileType","dossier");
                    queryWrapper.eq("typeId",archivesDoss.getTypeId());
                    queryWrapper.eq("classId",archivesDoss.getClassId());
                    queryWrapper.eq("isDelete","0");
                    queryWrapper.in("state",states);

                    Integer count = archivesDocMapper.selectCount(queryWrapper);

                    StringBuilder dossierNumStrBui=new StringBuilder();
                    Integer genDossierNumInt=Integer.parseInt(genDossierNum);
                    //if(count == null || count==0){
                        count++;
                        dossierNumStrBui.append(count);
                        int s=genDossierNumInt-dossierNumStrBui.length();
                        for (int k=0;k<s;k++){
                            dossierNumStrBui.insert(0,0);
                        }
                    //}
                    if(dossierNumStrBui.length()>0) archivesDoss.setDossierNum(dossierNumStrBui.toString());

                }
                archivesDocMapper.insert(archivesDoss);
            }else{
                archivesDoss=archivesDoc1;
                String dossPages2= archivesDoss.getPages();
                if(StringUtils.isNotEmpty(dossPages2)){
                    dossPages= Integer.parseInt(dossPages2);
                }
            }

            //解析对应案卷下的对应案件的doc.xml
            for(int j=0;j<listDocPath.size();j++){
                String docPath=listDocPath.get(j);
                if(!docPath.contains(dossPath)){
                    continue;
                }
                Map<String,List> mapDoc = XmlDomUtil.domXml(zipPath+docPath+"/doc.xml");
                //设置卷内文件信息
                int itemNum=j+1;
                ArchivesDoc dossDoc=getArchivesDossDoc(mapDoc,archivesDoss,appId,zipPath,itemNum,workOrder,pdfList,genItemNum);
                if(dossDoc.getId() == null){
                    result.put("code","508");
                    result.put("msg",dossDoc.getFourResult());
                    return JSON.toJSONString(result);
                }
                dossPages=dossPages+Integer.parseInt(dossDoc.getPages());
            }

            QueryWrapper<ArchivesDoc> dossWrapper=new QueryWrapper<>();
            dossWrapper.select("sum(pages) pages,count(id) itemCount");
            dossWrapper.eq("dossierId",archivesDoss.getId());
            ArchivesDoc doss= archivesDocMapper.selectOne(dossWrapper);

            archivesDoss.setPages(doss.getPages());
            archivesDoss.setItemCount(doss.getItemCount());

            archivesDocMapper.updateById(archivesDoss);

        }
        return null;
    }

    /**
     * @description: 上传附件
     * @date: 2022/10/24
     */
    private String uploadFile(ArchivesDoc doc,String filePath,String fileName,String appId){

        File file=new File(filePath);
        MultipartFile multipartFile= FileBaseUtil.getMultipartFile(file);
        String extName=FileBaseUtil.getFileExtName(file);

        Result<String> upload = uploadService.localUpload("receive/"+appId+"/", doc.getId()+"", multipartFile);
        if(StringUtils.isNotEmpty(upload.getData())){
            ArchivesDocFile archivesDocFile = new ArchivesDocFile();
            archivesDocFile.setDocId(doc.getId());
            archivesDocFile.setFileUrl(upload.getData());
            archivesDocFile.setItemNum(doc.getItemNum());
            archivesDocFile.setExtName(extName);
            archivesDocFile.setCreateTime(LocalDateTime.now());
            archivesDocFile.setIsRealName(true);
            archivesDocFile.setIsOA(false);
            if(fileName.contains(extName)){
                archivesDocFile.setFileName(fileName);
            }else {
                archivesDocFile.setFileName(fileName+"."+extName);
            }


            //挂接文件
            Result<String> mountFile = mountService.baseMountFile(archivesDocFile);

            //对案件无效，只对案卷有效
            /*if("1000".equals(mountFile.getCode())){
                UpdateWrapper<ArchivesDocFile> fileUpdateWrapper=new UpdateWrapper<>();
                fileUpdateWrapper.eq("id",archivesDocFile.getId());
                ArchivesDocFile archivesDocFile1=new ArchivesDocFile();
                archivesDocFile1.setFileName(fileName);
                fileMapper.update(archivesDocFile1,fileUpdateWrapper);
            }*/
        }


        return null;
    }


    /**
     * @description: 下载ftp文件
     *  ftp服务器文件路径  本地保存路径   文件名称
     * @date: 2022/10/24
     */
    private boolean downZip(String downPath,String savePath,String fileName){
        try{
            Ftp ftp=new Ftp();

            ftp.setIpAddr(ftpIp);
            ftp.setPort(21);
            ftp.setUserName(ftpUserName);
            ftp.setPwd(ftpPwd);

            //公司智档在线服务器ip地址
            //ftp.setIpAddr("152.136.113.140");
            //ftp.setPort(21);
            //ftp.setUserName("ftps");
            //ftp.setPwd("yRXvB61qjo2c");

            //本地虚拟机ip地址
            //ftp.setIpAddr("192.168.157.128");
            //ftp.setPort(21);
            //ftp.setUserName("ftptest");
            //ftp.setPwd("ftptest");


            //ftp.setIpAddr("10.10.20.79");
            //ftp.setPort(21);
            //ftp.setUserName("ftps");
            //ftp.setPwd("kjWt1s#SH5@S");

            downPath=downPath.replace("//","/");
            savePath=savePath.replace("//","/");
            ftp.setPath(downPath);

            FtpUtil.connectFtp(ftp);

            boolean is=FtpUtil.downFile(ftp,savePath,fileName);
            if(is){
                System.out.println("zip包下载成功");
                return true;
            }else {
                System.out.println("zip包下载失败");
                return false;
            }
        }catch(Exception e){
            e.printStackTrace();
            return false;
        }finally {
            FtpUtil.closeFtp();
        }
    }

    /**
     * @description: 判断任务单是否符合规定
     * @date: 2022/10/21
     */
    private boolean isWorkOrder (WorkOrder workOrder){

        if(workOrder.getAppId()==null || workOrder.getAppToken()==null || workOrder.getCompanyCode()==null || workOrder.getGdr()==null
            || workOrder.getGdsj()==null || workOrder.getRwblx()==null || workOrder.getRwdbt()==null || workOrder.getScmc()==null
            || workOrder.getRwdh()==null || workOrder.getSclj()==null || workOrder.getSl()==null || workOrder.getScdx()==null ) {
            return true;
        }
        return false;
    }

    /**
     * @description: 生成案卷内的案件类
     * @date: 2022/10/20
     */
    private  ArchivesDoc getArchivesDossDoc(Map<String, List> map,ArchivesDoc doss,String appId,
                                            String zipPath,int itemNum,WorkOrder workOrder,
                                            List<String> pdfList,String genItemNum){
        ArchivesDoc dossDoc=new ArchivesDoc();
        List<List<String>> listOne=map.get("1");
        for(int i=0;i<listOne.size();i++){
            List<String> list= listOne.get(i);
            //if(i==1) 任务单编号
            if(i==2){
                // 去重操作！！！/sys
                ArchivesDoc doc = archivesDocMapper.selectOne(new QueryWrapper<ArchivesDoc>().eq("itemCode",list.get(1)));
                if(doc!=null){
                    return doc;
                }else{
                    dossDoc.setItemCode(list.get(1)); // 源系统id
                }
            }
        }

        List<List<String>> listTwo=map.get("1_3->2");
        dossDoc.setSecret("0");
        dossDoc.setDossierId(doss.getId());
        dossDoc.setState(doss.getState());
        dossDoc.setFileType("doc");
        dossDoc.setItemNum(itemNum+"");
        dossDoc.setClassId(doss.getClassId());
        dossDoc.setFondsId(doss.getFondsId());
        dossDoc.setTypeId(doss.getTypeId());
        dossDoc.setArchivingTime(DateUtil.getCurrentTime());
        dossDoc.setItemCount("1");
        dossDoc.setDossierNum(doss.getDossierNum());
        for (int j=0;j<listTwo.size();j++){
            List<String> list=listTwo.get(j);
            //给案件字段赋值
            if ("ZB".equals(appId)){
                dossDoc.setDocFrom("4");
                dossDoc.setSource("ZB");
                getZbDossDoc(j,dossDoc,list);
            }
        }
        dossDoc.setDocTotalSize(workOrder.getScdx());
        dossDoc.setDutyCompany(workOrder.getCompanyCode());

        if(StringUtils.isNotEmpty(genItemNum)){
            QueryWrapper<ArchivesDoc> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("dossierId",doss.getId());
            Integer count = archivesDocMapper.selectCount(queryWrapper);
            StringBuilder itemNumStrBui=new StringBuilder();
            Integer genItemNumInt=Integer.parseInt(genItemNum);
            //if(count == null || count==0){
                count++;
                itemNumStrBui.append(count);
                int s=genItemNumInt-itemNumStrBui.length();
                for (int i=0;i<s;i++){
                    itemNumStrBui.insert(0,0);
                }
            //}
            if(itemNumStrBui.length()>0) dossDoc.setItemNum(itemNumStrBui.toString());
        }

        //四性检测
        Result r = archivesTestingFourService.fourDetection(dossDoc, workOrder, pdfList, zipPath);
        QueryWrapper<ArchivesTestingFourRecord> fourRecordQueryWrapper=new QueryWrapper<>();
        fourRecordQueryWrapper.eq("docId","-1");
        fourRecordQueryWrapper.eq("test","false");
        fourRecordQueryWrapper.eq("source","ZB");
        List<ArchivesTestingFourRecord> ArchivesTestingFourRecords= archivesTestingFourRecordMapper.selectList(fourRecordQueryWrapper);

        //四性检测
        if(ArchivesTestingFourRecords.size()>0){
            //四性检测未通过
            String msg="";
            for(int j=0;j<ArchivesTestingFourRecords.size();j++){
                msg=msg+ArchivesTestingFourRecords.get(j).getDescribes()+";";
            }
            dossDoc.setFourResult(msg);
            msg=msg.replace("true","");

            workOrder.setState("0");
            workOrder.setReason(msg);
            //workOrder.setFailCount(Integer.parseInt(workOrder.getSl())-i);
            //workOrder.setSuccessCount(Integer.parseInt(workOrder.getSl())-(Integer.parseInt(workOrder.getSl())-i));
            workOrder.setSuccessCount(0);
            workOrder.setFailCount(1);
            workOrderMapper.insert(workOrder);

            //删除四性检测记录
            Map<String, Object> map2 = new HashMap<>();
            map2.put("docId","-1");
            map2.put("source","ZB");
            archivesTestingFourRecordMapper.deleteByMap(map2);

            return dossDoc;
        }


        archivesDocMapper.insert(dossDoc);

        List<String> listFilePath= new ArrayList<>();
        List<String> listFileName= new ArrayList<>();
        if(StringUtils.isNotEmpty(dossDoc.getDocName()) && StringUtils.isNotEmpty(dossDoc.getDocPath())){
            listFileName.add(dossDoc.getDocName());
            listFilePath.add(dossDoc.getDocPath());
            //System.out.println("doc名称："+dossDoc.getDocName());
            //System.out.println("doc路径："+dossDoc.getDocPath());
        }
        for(String key:map.keySet()){
            //String regex="1_4->2_[\\d]->3";
            String regex = "1_4->2_([0-9][0-9]{0,1}|100)->3";
            /*if(!key.contains("1_4->2_")){
                continue;
            }*/
            if(!key.matches(regex)){
                continue;
            }
            List<List<String>> listThree=map.get(key);
            for (int j=0;j<listThree.size();j++){
                List<String> list=listThree.get(j);
                if(j==3) {
                    listFileName.add(list.get(1));  //文件名
                }
                if(j==7) listFilePath.add(list.get(1));  //存储路径
                //if(j==2) listFilePath.add(list.get(1));  //xml存储路径
            }

        }

        for (int j=0;j<listFilePath.size();j++){

            //if ("ZB".equals(appId)){
               // uploadFile(dossDoc,zipPath+listFilePath.get(j),listFileName.get(j/2),appId);
            //}else{
                uploadFile(dossDoc,zipPath+listFilePath.get(j),listFileName.get(j),appId);
            //}
        }


        return dossDoc;
    }

    /**
     * @description: 生成案卷类
     * @date: 2022/10/20
     */
    private ArchivesDoc getArchivesDoss(Map<String, List> map,String appId,Long fondsId,Long typeId){

        ArchivesDoc archivesDoc=new ArchivesDoc();
        List<List<String>> listOne= map.get("1");
        for(int i=0;i<listOne.size();i++){
            List<String> list= listOne.get(i);
            //if(i==0) 聚合层次
            //if(i==1) 任务单编号
            if(i==2)  archivesDoc.setItemCode(list.get(1)) ; // 源系统id
        }
        List<List<String>> listTwo= map.get("1_3->2");
        for(int i=0;i<listTwo.size();i++){
            List<String> list= listTwo.get(i);
            //生成对应系统的案卷
            if("ZB".equals(appId)){
                getZbDoss(i,archivesDoc,list,fondsId,typeId);
                archivesDoc.setDocFrom("4");  //文件来源
                archivesDoc.setSource("ZB");
                archivesDoc.setTypeId(typeId);
                archivesDoc.setFondsId(fondsId+"");
                archivesDoc.setArchivingTime(DateUtil.getCurrentTime());
            }

        }
        archivesDoc.setState("6");
        archivesDoc.setSecret("0");
        archivesDoc.setIsDelete("0");
        archivesDoc.setDossierId(0L);
        archivesDoc.setFileType("dossier");

        return archivesDoc;
    }

    /**
     * @description: 判断目录是否存在
     *
     * @date: 2022/10/24
     */
    private String isExists(String zipPath,List<String> listPath){
        for(int i=0;i<listPath.size();i++){
            File file=new File(zipPath+listPath.get(i));
            if(!file.exists()){
                return "解析失败："+listPath.get(i)+"目录不存在!";
            }
        }
        return "true";
    }

    /**
     * @description: 判断是否是一个json字符串
     *
     * @author: lig
     * @date: 2022/7/29
     */
    private boolean isJson(String str){
        try {
            JSONObject jsonStr= JSONObject.parseObject(str);
            return  true;
        } catch (Exception e) {
            return false;
        }
    }

    /**
     * @description: 获取案卷中的list.xml中案卷的目录
     *
     * @date: 2022/10/20
     */
    private List<String> getDossPath(Map<String, List> map){
        List<String> listPath=new ArrayList<>();
        //获取卷目录
        List<List<String>> listVol= map.get("1");
        for (List<String> list : listVol) {
            String str=list.get(2);
            str=str.split(",")[1].trim();
            String volPath=str.substring(0,str.lastIndexOf("]"));
            listPath.add(volPath);
        }
        return listPath;
    }

    /**
     * @description: 获取案卷中案件的list.xml中案件的目录
     *
     * @date: 2022/10/20
     */
    private List<String> getDossDocPath(Map<String, List> map){
        List<String> listPath=new ArrayList<>();
        List<List<String>> listVol= map.get("1");

        //获取案卷中的件目录
        for(int i=0;i<listVol.size();i++){
            List<List<String>> listDoc= map.get("1_"+i+"->2");
            for (List<String> list : listDoc) {
                String docPath=list.get(1).trim();
                listPath.add(docPath);
            }
        }
        return listPath;
    }

    /**
     * @description: 获取案件中的list.xml中案件的目录
     *
     * @date: 2022/10/25
     */
    private List<String> getDocPath(Map<String, List> map){
        List<String> listPath=new ArrayList<>();
        List<List<String>> listDoc= map.get("1");
        //获取案件的目录
        for(int i=0;i<listDoc.size();i++){
            listPath.add(listDoc.get(i).get(1));
        }
        return listPath;
    }

    /**
     * @description: 给离隰oa案件元数据赋值
     *
     * @date: 2022/10/28
     */
    private void getOaDoc(int j,ArchivesDoc doc,List<String> list,String flowName){
        if(j==1) doc.setArchivalYear(list.get(1));  //年度
        //if(j==2) doc.setDutyPeople(list.get(1));  //责任者
        if(j==3) doc.setItemCount(list.get(1));  //文件件数
        if(flowName.contains("发文")){
            if(j==4) {
                doc.setSysArchivingTime(list.get(1));
                doc.setStartTime(list.get(1));
            }  //成文日期
            //if(j==5) list.get(1);  //附件
            if(j==6) doc.setWritingNum(list.get(1));  //文号
            if(j==7) doc.setPages(list.get(1));//文件总页数
            //if(j==8) list.get(1);   //秘密级别
            if(j==9) doc.setTitle(list.get(1));  //题名
            //if(j==10) doc.setExt20(list.get(1));  //拟稿单位
            if(j==10) doc.setDutyPeople(list.get(1));  //拟稿单位-责任者
            //if(j==11) list.get(1);   //监印
            //if(j==12) list.get(1);   //共印份数
            if(j==13) doc.setExt19(list.get(1));  //机关代字
            if(j==14) doc.setApplicant(list.get(1));  //拟稿人
            if(j==15) doc.setExt18(list.get(1));  //校对
            if(j==16) doc.setExt17(list.get(1));  //主送
            if(j==17) doc.setExt16(list.get(1));  //抄送
        }else{
            //if(j==4) list.get(1);  //附件
            if(j==5) doc.setWritingNum(list.get(1));  //文号
            if(j==6) doc.setPages(list.get(1));//文件总页数
            if(j==7) {
                doc.setSysArchivingTime(list.get(1));  //收文日期
                doc.setStartTime(list.get(1));
            }
            //if(j==8) doc.setExt15(list.get(1));  //来文单位
            if(j==8) doc.setDutyPeople(list.get(1));  //来文单位-责任者
            if(j==9) doc.setTitle(list.get(1));  //题名
        }
    }

    /**
     * 给集团OA元数据赋值
     * @param j
     * @param doc
     * @param list
     */
    private void getJtOaDoc(int j,ArchivesDoc doc,List<String> list){

        if(j==0){} //来源
        if(j==1) doc.setTitle(list.get(1)); //题名
        if(j==2) doc.setArchivalYear(list.get(1)); //年度
        if(j==3) doc.setWritingNum(list.get(1)); //文号
        //if(j==4){} //文种
        if(j==5) doc.setDutyPeople(list.get(1)); //责任者
        if(j==6){
            doc.setSysArchivingTime(list.get(1));
            doc.setStartTime(list.get(1));
        } //成文日期
        if(j==7) doc.setItemCount(list.get(1)); //文件件数
        if(j==8) doc.setPages(list.get(1)); //文件总页数
        if(j==9) doc.setExt17(list.get(1));  //主送
        if(j==10) doc.setExt16(list.get(1)); //抄送
        //if(j==11){} //紧急程度
        if(j==12) doc.setRemark(list.get(1)); //备注
        //if(j==13){} //移交人
        //if(j==14){} //移交部门
        //if(j==15){} //移交时间
    }

    /**
     * @description: 给ZB案卷元数据赋值
     *
     * @date: 2022/10/28
     */
    private void getZbDoss(int i,ArchivesDoc doss,List<String> list,Long fondsId,Long typeId){
        if(i==0) doss.setTitle(list.get(1)); //题名
        if(i==1){
            QueryWrapper<ArchivesClass> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("extId",list.get(1));
            ArchivesClass archivesClass = archivesClassMapper.selectOne(queryWrapper);
            if(archivesClass!=null){
                doss.setClassId(archivesClass.getId());
            }
            doss.setLmId(list.get(1));
        };   // 施工合同段id
        //if(i==3) ; //分项工程id
        if(i==5){
            String caiLiao= list.get(1); //  抽检 = 监理   自检 = 施工
            if("抽检".equals(caiLiao)){
                if(doss.getLmId().equals("10") || doss.getLmId().equals("67")){
                    doss.setClassId(1040L);
                }else if( doss.getLmId().equals("222") ){
                    doss.setClassId(1041L);
                }
            }
        }


        /*if(i==1) doss.setDutyPeople(list.get(1));  //责任者
        if(i==2) {   //保管期限
            QueryWrapper<Dic> dicQueryWrapper=new QueryWrapper<>();
            dicQueryWrapper.eq("dicType","storagePeriod");
            dicQueryWrapper.eq("dicValue",list.get(1));
            Dic dic= dicMapper.selectOne(dicQueryWrapper);
            doss.setStoragePeriod(dic.getDicCode());
        };
        if(i==3) doss.setItemName(list.get(1)); //项目名称
        if(i==4) doss.setItemCount(list.get(1));//文件件数
        if(i==5) {  // 设置 classId    分项工程id
            QueryWrapper<ArchivesClass> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("extId",list.get(1));
            ArchivesClass archivesClass = archivesClassMapper.selectOne(queryWrapper);
            if(archivesClass!=null){
                doss.setClassId(archivesClass.getId());
            }
        }
        if(i==7) doss.setRemark(list.get(1)) ; // 备注*/

    }

    /**
     * @description: 给oa案卷中案件的元数据赋值
     *
     * @date: 2022/10/28
     */
    private void getZbDossDoc(int i,ArchivesDoc doc,List<String> list){
        //聚合层次
        //文件标识方案
        //文件编号
        if(i==3) doc.setTitle(list.get(1)); //文件名称
        if(i==4) doc.setDutyPeople(list.get(1)); //责任者
        if(i==5) doc.setStartTime(list.get(1));//日期
        if(i==6) doc.setPages(list.get(1));//页数
        if(i==7) doc.setRemark(list.get(1));//备注
        //数字摘要值
        //关键词
        //摘要
        if(i==11) doc.setExt20(list.get(1));//生成方式
        if(i==12) doc.setExt19(list.get(1));//桩号
        if(i==13) doc.setExt18(list.get(1));//高程
        if(i==14) doc.setExt17(list.get(1));//质量等级
        if(i==35) doc.setDocName(list.get(1)); //doc名称
        if(i==36) doc.setDocPath(list.get(1)); //doc存储位置
        //if(i==15) doc.setExt16(list.get(1));
        //组件人
        //组件时间
        //语种
        //责任者机构
        //责任者标识码
        //责任者名称
        //责任者手机号
        //相关实体标识
        //关系名称
        //关系开始日期
        //关系描述
        //建设项目
        //施工合同段
        //施工合同段标识
        //工程施工阶段
        //工程施工阶段标识
        //单位工程
        //单位工程标识码
        //分部工程
        //分部工程标识码
        //分项工程
        //分项工程标识码
        //业务标识方案
        //封装包创建时间
        //封装包创建单位
        //数据来源
        //服务器IP
        //客户端IP
    }


}

